package com.safety.web.controller;

import com.safety.core.util.Data;
import com.safety.web.entity.Quickmedicine;
import com.safety.web.service.QuickmedicineService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2017/2/28.
 */
@Controller
@RequestMapping("/quickmedicine")
public class QuickmedicineController {
    @Resource
    private QuickmedicineService quickmedicineService;
    @RequestMapping("/quickmedicineselect")
    @ResponseBody
    public Map<String, Object> selectquickmedicine() {
        Map<String, Object> mapa = new LinkedHashMap<String, Object>();
        List<Quickmedicine> list = quickmedicineService.quickmedicineselect();
        List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> list2 = new ArrayList<Map<String, Object>>();
        Map<String, Object> listForArea = new LinkedHashMap<String, Object>();
        List<Map<String, Object>> listForArea1 = new ArrayList<>();
            for (Quickmedicine classList : list) {
                if(classList.getQuid()==1){
                Map<String, Object> map = new LinkedHashMap<>();
                map.put("heaId", classList.getId());
                map.put("heaimg", Data.URL.base +classList.getQuickimg());
                list1.add(map);
                }
                if(classList.getQuid()==2){
                    Map<String, Object> map= new LinkedHashMap<>();
                    map.put("heaId", classList.getId());
                    map.put("heaimg", Data.URL.base +classList.getQuickimg());
                    list2.add(map);
                }

            }
            listForArea.put("fastabove", list1);
            listForArea.put("fastbelow", list2);
            listForArea1.add(listForArea);
        mapa.put("code", 200);
        mapa.put("quickm", listForArea1);
        return mapa;
    }
    @RequestMapping("/carouselfigure")
    @ResponseBody
    public Map<String, Object> carouselfigure() {
        Map<String, Object> mapa = new LinkedHashMap<String, Object>();
        List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();
        List<Quickmedicine> list = quickmedicineService.quickmedicineselect();
        for (Quickmedicine classList : list) {
            if (classList.getQuid() == 3) {
                Map<String, Object> map = new LinkedHashMap<>();
                map.put("heaId", classList.getId());
                map.put("heaimg", Data.URL.base + classList.getQuickimg());
                list1.add(map);
            }
        }
        mapa.put("code", 200);
        mapa.put("figure", list1);
        return mapa;
    }
    @RequestMapping("/carouselfigurefour")
    @ResponseBody
    public Map<String, Object> carouselfigurefour() {
        Map<String, Object> mapa= new LinkedHashMap<String, Object>();
        List<Map<String, Object>> list1 = new ArrayList<Map<String, Object>>();
        List<Quickmedicine> list = quickmedicineService.quickmedicineselect();
        for (Quickmedicine classList : list) {
            if (classList.getQuid() == 4) {
                Map<String, Object> map = new LinkedHashMap<>();
                map.put("heaId", classList.getId());
                map.put("heaimg", Data.URL.base + classList.getQuickimg());
                list1.add(map);
            }
        }
        mapa.put("code", 200);
        mapa.put("fourfigure", list1);
        return mapa;
    }

}
